package com.it;

import java.util.Scanner;

public class RandomDemo {
    public static void main(String[] args) {
        //猜数字
        int v = (int) (Math.random() * 1000);//确认随机值1-1000
        System.out.println("v = " + v);
        Scanner scanner = new Scanner(System.in);
        int num;

        do {
            System.out.println("请输入你要猜的数字");
            num = scanner.nextInt();
            if (num > v) {
                System.out.println("猜大了");
            } else if (num < v) {
                System.out.println("猜小了");
            }
        } while (num != v);
        System.out.println("恭喜你答对了");
    }
}
